/**
 * Created by LaoXu on 2017/12/20.
 * @description:店铺页面功能实现
 */

/*
 <li>
 <a>
 <div class="meishi-img">
 <img src="images/imgs01.png"/>
 <div class="shade fontSmalSize">
 <img src="images/ping-img.png"/>
 <p><span>5</span>分好评</p>
 </div>
 <div class="shop-name fontSmalSize">
 多多餐厅
 </div>

 <div class="star">
 <div class="star-default">
 <div class="star-press"></div>
 </div>
 </div>
 </div>
 </a>
 </li>
 */

require(['config'], function () {
    require(['jquery', 'xutil'], function ($, xutil) {
        // 获取DOM节点
        var $meishiWrap = $('.meishi-wrap');
        var $ul = $meishiWrap.children('ul');

        // 从服务器端获取数据
        $.get(xutil.baseUrl + '/api/shop/getDataList', function (result) {

            console.log(result);
            if (result.code === 0) {
                var datas = result.datas,
                    str = "";

                datas.forEach(function (item, index) {
                    str += ` <li>
                    <a href="./foods.html?shop_id=${item.shop_id}">
                        <div class="meishi-img">
                            <img src="${item.shop_pic}"/>
                            <div class="shade fontSmalSize">
                                <img src="images/ping-img.png"/>
                                <p><span>${(parseInt(item.pingjia) / 20).toFixed(1)}</span>分好评</p>
                            </div>
                            <div class="shop-name fontSmalSize">
                                ${item.shop_name}
                            </div>

                            <div class="star">
                                <div class="star-default">
                                    <div class="star-press" style="width: ${item.pingjia}%;"></div>
                                </div>
                            </div>
                        </div>
                    </a>
                </li>`;
                });
                str += str;
                $ul.append(str);
            } else {
                console.log(result.code)
            }
        });

        function Shop() {

        }


    });

});
